#ifndef __MSGQUEUE_H_V2__
#define __MSGQUEUE_H_V2__

// #include "kal_general_types.h"
#include "os_config.h"
// #include "globle_include.h"
#include "os_include.h"

#ifndef __NOT_RTOS__
#define MSG_QUEUE_NAME_LEN_MAX   RT_NAME_MAX // 8 RT_NAME_MAX

struct msg_queue {
	char  pname[MSG_QUEUE_NAME_LEN_MAX];
	size_t 	msg_size;
	queue_msg_t msg_qu;
};

typedef struct msg_queue msg_queue_t;
typedef struct msg_queue * msg_queue_id;


extern msg_queue_id msg_queue_create(const char *pname,size_t msg_size, size_t msg_numitems);
extern int msg_queue_free(msg_queue_id msgid);


extern int msg_enqueue(msg_queue_id msgid,void * pmsg);
extern int msg_enqueue_realsize(msg_queue_id msgid,void * pmsg,size_t msg_size);
extern int msg_enqueue_waitTick(msg_queue_id msgid,void * pmsg,tick_timeout_t tick);
extern int msg_enqueue_nowait(msg_queue_id msgid,void * pmsg);

extern int msg_dequeue(msg_queue_id msgid,void * pmsg);
extern int msg_dequeue_waitTick(msg_queue_id msgid,void * pmsg,tick_timeout_t tick);


extern int msg_dequeue_clean(msg_queue_id msgid);

#if defined(ENABLE_FREERTOS_SYSAPI)
extern int msg_enqueue_isr(msg_queue_id msgid,void * pmsg);
extern int msg_enqueue_nowait_isr(msg_queue_id msgid,void * pmsg);
#else
#define msg_enqueue_isr  			msg_enqueue
#define msg_enqueue_nowait_isr  	msg_enqueue_nowait
#endif

#endif

#endif

